using System;
using System.Collections.Generic;
using System.Text;
using Wrath.Xml;
using Wrath.RuleForge.Interfaces;

namespace Wrath.RuleForge
{
    public static class EventBroker
    {
        #region Messaging Events & Handler

        public class MessageEventArgs : EventArgs
        {
            private string message;

            public MessageEventArgs(string message)
            {
                this.message = message;
            }

            public string Message { get { return message; } }
        }
        public delegate void MessageEventHandler(MessageEventArgs messageEventArgs);

        #endregion

        public static event MessageEventHandler DebugMessage;
        public static void FireDebugMessage(MessageEventArgs messageEventArgs)
        {
            if (DebugMessage != null)
                DebugMessage(messageEventArgs);
        }

        #region File/Path handlers

        public class PathEventArgs : EventArgs
        {
            private string path;

            public PathEventArgs(string path)
            {
                this.path = path;
            }

            public string Path { get { return path; } }
        }
        public delegate void PathEventHandler(PathEventArgs pathEventArgs);

        #endregion

        public static event PathEventHandler RuleSetOpen;
        public static void FireRuleSetOpen(PathEventArgs pathEventArgs)
        {
            if (RuleSetOpen != null)
                RuleSetOpen(pathEventArgs);
        }

        public static event EventHandler RuleSetClose;
        public static void FireRuleSetClose()
        {
            if (RuleSetClose != null)
                RuleSetClose(null, null);
        }

        public static event PathEventHandler FrameSelected;
        public static void FireFrameSelected(PathEventArgs pathEventArgs)
        {
            if (FrameSelected != null)
                FrameSelected(pathEventArgs);
        }

        public static event PathEventHandler IconSelected;
        public static void FireIconSelected(PathEventArgs pathEventArgs)
        {
            if (IconSelected != null)
                IconSelected(pathEventArgs);
        }

        #region PropertyWrapper handlers

        public class ElementPropertyWrapperEventArgs : EventArgs
        {
            private IPropertyWrapper<Element> elementWrapper;

            public ElementPropertyWrapperEventArgs(IPropertyWrapper<Element> elementWrapper)
            {
                this.elementWrapper = elementWrapper;
            }

            public IPropertyWrapper<Element> ElementWrapper { get { return elementWrapper; } }
        }
        public delegate void ElementPropertyWrapperEventHandler(ElementPropertyWrapperEventArgs eventArgs);

        #endregion

        public static event ElementPropertyWrapperEventHandler RuleSetElementSelected;
        public static void FireRuleSetElementSelected(ElementPropertyWrapperEventArgs eventArgs)
        {
            if (RuleSetElementSelected != null)
                RuleSetElementSelected(eventArgs);
        }

        public static event EventHandler ElementPropertyChanged;
        public static void FireElementPropertyChanged(object data)
        {
            if (ElementPropertyChanged != null)
                ElementPropertyChanged(data, new EventArgs());
        }

        #region Element handlers

        public class ElementEventArgs : EventArgs
        {
            private Element element;

            public ElementEventArgs(Element element)
            {
                this.element = element;
            }

            public Element ElementData { get { return element; } }
        }
        public delegate void ElementEventHandler(ElementEventArgs eventArgs);

        #endregion

        public static event ElementEventHandler FrameDoubleClicked;
        public static void FireFrameDoubleClicked(ElementEventArgs elementArgs)
        {
            if (FrameDoubleClicked != null)
                FrameDoubleClicked(elementArgs);
        }

        public static event ElementEventHandler CustomDieDoubleClicked;
        public static void FireCustomDieDoubleClicked(ElementEventArgs elementArgs)
        {
            if (CustomDieDoubleClicked != null)
                CustomDieDoubleClicked(elementArgs);
        }

        public static event ElementEventHandler WindowClassDoubleClicked;
        public static void FireWindowClassDoubleClicked(ElementEventArgs elementArgs)
        {
            if (WindowClassDoubleClicked != null)
                WindowClassDoubleClicked(elementArgs);
        }

    }
}
